package com.mengniu.commerce.collect.service.impl.member;

import com.alibaba.fastjson.JSONObject;
import com.mengniu.commerce.collect.service.IPushStrategy;
import com.mengniu.commerce.collect.util.WeiMengResultUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
* @Description: 会员变更
* @Param:
* @return:
* @Author: zfw
* @Date: 2023/12/3
* @Date: 14:17
*/
@Slf4j
@Service("weimob_crm.customer_update" + IPushStrategy.BASE_NAME)
@RequiredArgsConstructor
public class WmMemberUpdatePushServiceImpl implements IPushStrategy {

    @Autowired
    private WmMemberServiceImpl wmMemberService;

    @Override
    public Object push(Long bosId,String entity) {
        log.info("会员变更事件entity:{}", entity);
        JSONObject jsonObject = JSONObject.parseObject(entity);
        String wid = jsonObject.getString("wid");
        List<String> list = Collections.singletonList(wid);
        wmMemberService.modifyMemberByMessage(bosId,list);
        return WeiMengResultUtil.restResult(0,"success");
    }
}
